<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>EasyQtSql: EasyQtSql/EasyQtSql_Transaction.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">EasyQtSql
   </div>
   <div id="projectbrief">Easy SQL data access helper for QtSql</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('_easy_qt_sql___transaction_8h_source.htm','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">EasyQtSql_Transaction.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_easy_qt_sql___transaction_8h.htm">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef EASYQTSQL_TRANSACTION_H</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define EASYQTSQL_TRANSACTION_H</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment">/*</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * The MIT License (MIT)</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * Copyright 2018 Alexey Kramin</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> * a copy of this software and associated documentation files (the</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> * &quot;Software&quot;), to deal in the Software without restriction, including</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> * without limitation the rights to use, copy, modify, merge, publish,</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment"> * distribute, sublicense, and/or sell copies of the Software, and to</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> * permit persons to whom the Software is furnished to do so, subject to</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> * the following conditions:</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> * The above copyright notice and this permission notice shall be</span></div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> * included in all copies or substantial portions of the Software.</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment"> * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,</span></div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment"> * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span></div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment"> * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE</span></div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="comment"> * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION</span></div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="comment"> * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION</span></div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="comment"> * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</span></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="comment">*/</span></div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#ifndef EASY_QT_SQL_MAIN</span></div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#include &lt;QtSql&gt;</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_easy_qt_sql___d_b_exception_8h.htm">EasyQtSql_DBException.h</a>&quot;</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_easy_qt_sql___non_query_result_8h.htm">EasyQtSql_NonQueryResult.h</a>&quot;</span></div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_easy_qt_sql___insert_query_8h.htm">EasyQtSql_InsertQuery.h</a>&quot;</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_easy_qt_sql___delete_query_8h.htm">EasyQtSql_DeleteQuery.h</a>&quot;</span></div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_easy_qt_sql___update_query_8h.htm">EasyQtSql_UpdateQuery.h</a>&quot;</span></div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_easy_qt_sql___prepared_query_8h.htm">EasyQtSql_PreparedQuery.h</a>&quot;</span></div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_easy_qt_sql___util_8h.htm">EasyQtSql_Util.h</a>&quot;</span></div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div><div class="line"><a name="l00067"></a><span class="lineno"><a class="line" href="class_database.htm">   67</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_database.htm">Database</a></div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;{</div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;   Q_DISABLE_COPY(<a class="code" href="class_database.htm">Database</a>)</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;</div><div class="line"><a name="l00080"></a><span class="lineno"><a class="line" href="class_database.htm#a252b2bb8aeb0c0a2509b0eddf0be3c4e">   80</a></span>&#160;   <span class="keyword">explicit</span> <a class="code" href="class_database.htm#a252b2bb8aeb0c0a2509b0eddf0be3c4e">Database</a> (<span class="keyword">const</span> QSqlDatabase &amp;db = QSqlDatabase())</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;   {</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;      <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a> = db.isValid() ? db : QSqlDatabase::database();</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;      <span class="keywordflow">if</span> (!<a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>.isOpen())</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;      {</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;         <span class="keywordflow">if</span> (!<a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>.open())</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;         {</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;<span class="preprocessor">            #ifdef DB_EXCEPTIONS_ENABLED</span></div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;            <span class="keywordflow">throw</span> <a class="code" href="class_d_b_exception.htm">DBException</a>(<a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>);</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;<span class="preprocessor">            #endif</span></div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;         }</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;      }</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;   }</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;</div><div class="line"><a name="l00095"></a><span class="lineno"><a class="line" href="class_database.htm#afe82d7c8e0e895c0b4f9fa08b4e3eb8e">   95</a></span>&#160;   <a class="code" href="class_database.htm#afe82d7c8e0e895c0b4f9fa08b4e3eb8e">Database</a>(<a class="code" href="class_database.htm">Database</a>&amp;&amp; other)</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;   {</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;      <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a> = other.m_db;</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;      other.m_db = QSqlDatabase();</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;   }</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;</div><div class="line"><a name="l00101"></a><span class="lineno"><a class="line" href="class_database.htm#a2a81e06933bf2ef5be2e59030a7e1e1c">  101</a></span>&#160;   <a class="code" href="class_database.htm">Database</a>&amp; <a class="code" href="class_database.htm#a2a81e06933bf2ef5be2e59030a7e1e1c">operator=</a>(<a class="code" href="class_database.htm">Database</a>&amp;&amp; other)</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;   {</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;      <span class="keywordflow">if</span> (<span class="keyword">this</span> == &amp;other) <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;      <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a> = other.m_db;</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;      other.m_db = QSqlDatabase();</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;      <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;   }</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;</div><div class="line"><a name="l00114"></a><span class="lineno"><a class="line" href="class_database.htm#a7bc0ce48d3711002d4e0490c826f7b5e">  114</a></span>&#160;   QSqlError <a class="code" href="class_database.htm#a7bc0ce48d3711002d4e0490c826f7b5e">lastError</a>()<span class="keyword"> const</span></div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>.lastError();</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;   }</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;</div><div class="line"><a name="l00124"></a><span class="lineno"><a class="line" href="class_database.htm#aae9f7e53275334c91655eeb7a2bde030">  124</a></span>&#160;   <a class="code" href="class_non_query_result.htm">NonQueryResult</a> <a class="code" href="class_database.htm#aae9f7e53275334c91655eeb7a2bde030">execNonQuery</a>(<span class="keyword">const</span> QString &amp;sql)<span class="keyword"> const</span></div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;      QSqlQuery q = <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>.exec(sql);</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;<span class="preprocessor">#ifdef DB_EXCEPTIONS_ENABLED</span></div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;      QSqlError <a class="code" href="class_database.htm#a7bc0ce48d3711002d4e0490c826f7b5e">lastError</a> = q.lastError();</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;      <span class="keywordflow">if</span> (<a class="code" href="class_database.htm#a7bc0ce48d3711002d4e0490c826f7b5e">lastError</a>.isValid())</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;         <span class="keywordflow">throw</span> <a class="code" href="class_d_b_exception.htm">DBException</a>(q);</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="class_non_query_result.htm">NonQueryResult</a>(q);</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;   }</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;</div><div class="line"><a name="l00145"></a><span class="lineno"><a class="line" href="class_database.htm#a05c1ac255cdba9781f8bf306801bca70">  145</a></span>&#160;   <a class="code" href="class_query_result.htm">QueryResult</a> <a class="code" href="class_database.htm#a05c1ac255cdba9781f8bf306801bca70">execQuery</a>(<span class="keyword">const</span> QString &amp;sql)<span class="keyword"> const</span></div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;      QSqlQuery q = <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>.exec(sql);</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;<span class="preprocessor">#ifdef DB_EXCEPTIONS_ENABLED</span></div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;      QSqlError <a class="code" href="class_database.htm#a7bc0ce48d3711002d4e0490c826f7b5e">lastError</a> = q.lastError();</div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;      <span class="keywordflow">if</span> (<a class="code" href="class_database.htm#a7bc0ce48d3711002d4e0490c826f7b5e">lastError</a>.isValid())</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;         <span class="keywordflow">throw</span> <a class="code" href="class_d_b_exception.htm">DBException</a>(q);</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;</div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;</div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="class_query_result.htm">QueryResult</a>(q);</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;   }</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;</div><div class="line"><a name="l00165"></a><span class="lineno"><a class="line" href="class_database.htm#a8388689590c1f3adeabd2972b221bcb2">  165</a></span>&#160;   <a class="code" href="class_insert_query.htm">InsertQuery</a> <a class="code" href="class_database.htm#a8388689590c1f3adeabd2972b221bcb2">insertInto</a>(<span class="keyword">const</span> QString &amp;table)<span class="keyword"> const</span></div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;      <a class="code" href="class_insert_query.htm">InsertQuery</a> query(table, <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>);</div><div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;</div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;      <span class="keywordflow">return</span> query;</div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;   }</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;</div><div class="line"><a name="l00176"></a><span class="lineno"><a class="line" href="class_database.htm#a44fca4a9c9241481a87d59f529e98b9e">  176</a></span>&#160;   <a class="code" href="class_delete_query.htm">DeleteQuery</a> <a class="code" href="class_database.htm#a44fca4a9c9241481a87d59f529e98b9e">deleteFrom</a>(<span class="keyword">const</span> QString &amp;table)<span class="keyword"> const</span></div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;      <a class="code" href="class_delete_query.htm">DeleteQuery</a> query(table, <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>);</div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;</div><div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;      <span class="keywordflow">return</span> query;</div><div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;   }</div><div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;</div><div class="line"><a name="l00187"></a><span class="lineno"><a class="line" href="class_database.htm#a2d8dad3df4134306749582216bd437e0">  187</a></span>&#160;   <a class="code" href="class_update_query.htm">UpdateQuery</a> <a class="code" href="class_database.htm#a2d8dad3df4134306749582216bd437e0">update</a>(<span class="keyword">const</span> QString &amp;table)<span class="keyword"> const</span></div><div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;      <a class="code" href="class_update_query.htm">UpdateQuery</a> query(table, <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>);</div><div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;      <span class="keywordflow">return</span> query;</div><div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;   }</div><div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;</div><div class="line"><a name="l00199"></a><span class="lineno"><a class="line" href="class_database.htm#a03e2c9113452bb52bb7018ef2366bce1">  199</a></span>&#160;   <a class="code" href="class_prepared_query.htm">PreparedQuery</a> <a class="code" href="class_database.htm#a03e2c9113452bb52bb7018ef2366bce1">prepare</a>(<span class="keyword">const</span> QString &amp;sql, <span class="keywordtype">bool</span> forwardOnly = <span class="keyword">true</span>)<span class="keyword"> const</span></div><div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;      <a class="code" href="class_prepared_query.htm">PreparedQuery</a> query(sql, <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>, forwardOnly);</div><div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;</div><div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;      <span class="keywordflow">return</span> query;</div><div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;   }</div><div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;</div><div class="line"><a name="l00209"></a><span class="lineno"><a class="line" href="class_database.htm#a0076431e130f7815ca7a3ae8ec7284ef">  209</a></span>&#160;   QSqlDatabase &amp;<a class="code" href="class_database.htm#a0076431e130f7815ca7a3ae8ec7284ef">qSqlDatabase</a>()</div><div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;   {</div><div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>;</div><div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;   }</div><div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;</div><div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;   <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Func&gt;</div><div class="line"><a name="l00229"></a><span class="lineno"><a class="line" href="class_database.htm#a7a13f4fc603fb829f123894d9abd6ea7">  229</a></span>&#160;   <span class="keywordtype">int</span> <a class="code" href="class_database.htm#a7a13f4fc603fb829f123894d9abd6ea7">each</a> (<span class="keyword">const</span> QString &amp;query, Func&amp;&amp; f)<span class="keyword"> const</span></div><div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;      <a class="code" href="class_query_result.htm">QueryResult</a> res = <a class="code" href="class_database.htm#a05c1ac255cdba9781f8bf306801bca70">execQuery</a>(query);</div><div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;</div><div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="class_util.htm#ab212a05ceda1f1060b772f6908253af2">Util::each</a>(res, f);</div><div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;   }</div><div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;</div><div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;   <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Func&gt;</div><div class="line"><a name="l00251"></a><span class="lineno"><a class="line" href="class_database.htm#ad2283c7025501aafc33530d19beb02b4">  251</a></span>&#160;   <span class="keywordtype">int</span> <a class="code" href="class_database.htm#ad2283c7025501aafc33530d19beb02b4">first</a> (<span class="keyword">const</span> QString &amp;query, Func&amp;&amp; f)<span class="keyword"> const</span></div><div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;      <a class="code" href="class_query_result.htm">QueryResult</a> res = <a class="code" href="class_database.htm#a05c1ac255cdba9781f8bf306801bca70">execQuery</a>(query);</div><div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;</div><div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="class_util.htm#a08e77f4051011d51e9d79339a839580a">Util::first</a>(res, f);</div><div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;   }</div><div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;</div><div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;   <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Func&gt;</div><div class="line"><a name="l00275"></a><span class="lineno"><a class="line" href="class_database.htm#a3b1fb50c3263775351fc981fda798207">  275</a></span>&#160;   <span class="keywordtype">int</span> <a class="code" href="class_database.htm#a3b1fb50c3263775351fc981fda798207">range</a>(<span class="keyword">const</span> QString &amp;query, <span class="keywordtype">int</span> start, <span class="keywordtype">int</span> count, Func&amp;&amp; f)<span class="keyword"> const</span></div><div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;      <a class="code" href="class_query_result.htm">QueryResult</a> res = <a class="code" href="class_database.htm#a05c1ac255cdba9781f8bf306801bca70">execQuery</a>(query);</div><div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;</div><div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="class_util.htm#af0d70a7ab17cd3f445cfeda22e367185">Util::range</a>(res, start, count, f);</div><div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;   }</div><div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;</div><div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;   <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Func&gt;</div><div class="line"><a name="l00298"></a><span class="lineno"><a class="line" href="class_database.htm#a91583d42e701fb399563facc3c3c58c0">  298</a></span>&#160;   <span class="keywordtype">int</span> <a class="code" href="class_database.htm#a91583d42e701fb399563facc3c3c58c0">top</a>(<span class="keyword">const</span> QString &amp;query, <span class="keywordtype">int</span> topCount, Func&amp;&amp; f)<span class="keyword"> const</span></div><div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;      <a class="code" href="class_query_result.htm">QueryResult</a> res = <a class="code" href="class_database.htm#a05c1ac255cdba9781f8bf306801bca70">execQuery</a>(query);</div><div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;</div><div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="class_util.htm#a8b0d3aaa507f4f4add129795a2cd6247">Util::top</a>(res, topCount, f);</div><div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;   }</div><div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;</div><div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;   <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><a name="l00311"></a><span class="lineno"><a class="line" href="class_database.htm#a909783661db7d15e0b0adca5a96db4de">  311</a></span>&#160;   T <a class="code" href="class_database.htm#a909783661db7d15e0b0adca5a96db4de">scalar</a>(<span class="keyword">const</span> QString &amp;query)<span class="keyword"> const</span></div><div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;      <a class="code" href="class_query_result.htm">QueryResult</a> res = <a class="code" href="class_database.htm#a05c1ac255cdba9781f8bf306801bca70">execQuery</a>(query);</div><div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;</div><div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;      res.<a class="code" href="class_query_result.htm#a1c756382c20c126979b28715d529c054">next</a>();</div><div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;</div><div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;      <span class="keywordflow">return</span> res.<a class="code" href="class_query_result.htm#a5e3b49cb821efecac406606d9e3adb13">scalar</a>&lt;T&gt;();</div><div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;   }</div><div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;</div><div class="line"><a name="l00325"></a><span class="lineno"><a class="line" href="class_database.htm#a39dbcd9a97f4e3c38c8c5ba48e445216">  325</a></span>&#160;   QVariant <a class="code" href="class_database.htm#a39dbcd9a97f4e3c38c8c5ba48e445216">scalar</a>(<span class="keyword">const</span> QString &amp;query)<span class="keyword"> const</span></div><div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;      <a class="code" href="class_query_result.htm">QueryResult</a> res = <a class="code" href="class_database.htm#a05c1ac255cdba9781f8bf306801bca70">execQuery</a>(query);</div><div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160;</div><div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;      res.<a class="code" href="class_query_result.htm#a1c756382c20c126979b28715d529c054">next</a>();</div><div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;</div><div class="line"><a name="l00331"></a><span class="lineno">  331</span>&#160;      <span class="keywordflow">return</span> res.<a class="code" href="class_query_result.htm#a5e3b49cb821efecac406606d9e3adb13">scalar</a>();</div><div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;   }</div><div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;</div><div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;<span class="keyword">protected</span>:</div><div class="line"><a name="l00335"></a><span class="lineno"><a class="line" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">  335</a></span>&#160;   QSqlDatabase <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>;</div><div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;};</div><div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;</div><div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;</div><div class="line"><a name="l00398"></a><span class="lineno"><a class="line" href="class_transaction.htm">  398</a></span>&#160;<span class="keyword">class  </span><a class="code" href="class_transaction.htm">Transaction</a> : <span class="keyword">public</span> <a class="code" href="class_database.htm">Database</a></div><div class="line"><a name="l00399"></a><span class="lineno">  399</span>&#160;{</div><div class="line"><a name="l00400"></a><span class="lineno">  400</span>&#160;   Q_DISABLE_COPY(<a class="code" href="class_transaction.htm">Transaction</a>)</div><div class="line"><a name="l00401"></a><span class="lineno">  401</span>&#160;</div><div class="line"><a name="l00402"></a><span class="lineno">  402</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00403"></a><span class="lineno">  403</span>&#160;</div><div class="line"><a name="l00404"></a><span class="lineno"><a class="line" href="class_transaction.htm#a9fed08d5643b66471a6e9fc75f351117">  404</a></span>&#160;   <span class="keyword">explicit</span> <a class="code" href="class_transaction.htm#a9fed08d5643b66471a6e9fc75f351117">Transaction</a> (<span class="keyword">const</span> QSqlDatabase &amp;db = QSqlDatabase())</div><div class="line"><a name="l00405"></a><span class="lineno">  405</span>&#160;     : <a class="code" href="class_database.htm">Database</a>(db)</div><div class="line"><a name="l00406"></a><span class="lineno">  406</span>&#160;     , m_commited(false)</div><div class="line"><a name="l00407"></a><span class="lineno">  407</span>&#160;     , m_started(false)</div><div class="line"><a name="l00408"></a><span class="lineno">  408</span>&#160;   {      </div><div class="line"><a name="l00409"></a><span class="lineno">  409</span>&#160;      m_started = <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>.transaction();</div><div class="line"><a name="l00410"></a><span class="lineno">  410</span>&#160;</div><div class="line"><a name="l00411"></a><span class="lineno">  411</span>&#160;<span class="preprocessor">      #ifdef DB_EXCEPTIONS_ENABLED</span></div><div class="line"><a name="l00412"></a><span class="lineno">  412</span>&#160;      <span class="keywordflow">if</span> (!m_started)</div><div class="line"><a name="l00413"></a><span class="lineno">  413</span>&#160;      {</div><div class="line"><a name="l00414"></a><span class="lineno">  414</span>&#160;         <span class="keywordflow">throw</span> <a class="code" href="class_d_b_exception.htm">DBException</a>(<a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>);</div><div class="line"><a name="l00415"></a><span class="lineno">  415</span>&#160;      }</div><div class="line"><a name="l00416"></a><span class="lineno">  416</span>&#160;<span class="preprocessor">      #endif</span></div><div class="line"><a name="l00417"></a><span class="lineno">  417</span>&#160;   }</div><div class="line"><a name="l00418"></a><span class="lineno">  418</span>&#160;</div><div class="line"><a name="l00419"></a><span class="lineno"><a class="line" href="class_transaction.htm#a25916a5c0268d3b24a1fe17acf49fd95">  419</a></span>&#160;   <a class="code" href="class_transaction.htm#a25916a5c0268d3b24a1fe17acf49fd95">Transaction</a> (<a class="code" href="class_transaction.htm">Transaction</a>&amp;&amp; other)</div><div class="line"><a name="l00420"></a><span class="lineno">  420</span>&#160;      : <a class="code" href="class_database.htm">Database</a>(std::move(other))</div><div class="line"><a name="l00421"></a><span class="lineno">  421</span>&#160;   {</div><div class="line"><a name="l00422"></a><span class="lineno">  422</span>&#160;      m_commited = other.m_commited;</div><div class="line"><a name="l00423"></a><span class="lineno">  423</span>&#160;      m_started  = other.m_started;</div><div class="line"><a name="l00424"></a><span class="lineno">  424</span>&#160;</div><div class="line"><a name="l00425"></a><span class="lineno">  425</span>&#160;      other.m_commited = <span class="keyword">false</span>;</div><div class="line"><a name="l00426"></a><span class="lineno">  426</span>&#160;      other.m_started  = <span class="keyword">false</span>;</div><div class="line"><a name="l00427"></a><span class="lineno">  427</span>&#160;   }</div><div class="line"><a name="l00428"></a><span class="lineno">  428</span>&#160;</div><div class="line"><a name="l00429"></a><span class="lineno"><a class="line" href="class_transaction.htm#a384204be2d6c76f7f6d20d612f487e71">  429</a></span>&#160;   <a class="code" href="class_transaction.htm">Transaction</a>&amp; <a class="code" href="class_transaction.htm#a384204be2d6c76f7f6d20d612f487e71">operator=</a>(<a class="code" href="class_transaction.htm">Transaction</a>&amp;&amp; other)</div><div class="line"><a name="l00430"></a><span class="lineno">  430</span>&#160;   {</div><div class="line"><a name="l00431"></a><span class="lineno">  431</span>&#160;      m_started  = other.m_started;</div><div class="line"><a name="l00432"></a><span class="lineno">  432</span>&#160;      m_commited = other.m_commited;</div><div class="line"><a name="l00433"></a><span class="lineno">  433</span>&#160;</div><div class="line"><a name="l00434"></a><span class="lineno">  434</span>&#160;      other.m_commited = <span class="keyword">false</span>;</div><div class="line"><a name="l00435"></a><span class="lineno">  435</span>&#160;      other.m_started  = <span class="keyword">false</span>;</div><div class="line"><a name="l00436"></a><span class="lineno">  436</span>&#160;</div><div class="line"><a name="l00437"></a><span class="lineno">  437</span>&#160;      <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span><a class="code" href="class_transaction.htm">Transaction</a>&amp;<span class="keyword">&gt;</span>(<a class="code" href="class_database.htm#a2a81e06933bf2ef5be2e59030a7e1e1c">Database::operator=</a>(std::move(other)));</div><div class="line"><a name="l00438"></a><span class="lineno">  438</span>&#160;   }</div><div class="line"><a name="l00439"></a><span class="lineno">  439</span>&#160;</div><div class="line"><a name="l00440"></a><span class="lineno"><a class="line" href="class_transaction.htm#a362b0d2524d0c799165190517192dca9">  440</a></span>&#160;   <a class="code" href="class_transaction.htm#a362b0d2524d0c799165190517192dca9">~Transaction</a>()</div><div class="line"><a name="l00441"></a><span class="lineno">  441</span>&#160;   {</div><div class="line"><a name="l00442"></a><span class="lineno">  442</span>&#160;      <span class="keywordflow">if</span> (<a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>.isValid() &amp;&amp; !m_commited)</div><div class="line"><a name="l00443"></a><span class="lineno">  443</span>&#160;      {</div><div class="line"><a name="l00444"></a><span class="lineno">  444</span>&#160;         <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>.rollback();</div><div class="line"><a name="l00445"></a><span class="lineno">  445</span>&#160;      }</div><div class="line"><a name="l00446"></a><span class="lineno">  446</span>&#160;   }</div><div class="line"><a name="l00447"></a><span class="lineno">  447</span>&#160;</div><div class="line"><a name="l00455"></a><span class="lineno"><a class="line" href="class_transaction.htm#a7388031cba0416d48e03e3f7acd5ca6a">  455</a></span>&#160;   <span class="keywordtype">bool</span> <a class="code" href="class_transaction.htm#a7388031cba0416d48e03e3f7acd5ca6a">commit</a>()</div><div class="line"><a name="l00456"></a><span class="lineno">  456</span>&#160;   {</div><div class="line"><a name="l00457"></a><span class="lineno">  457</span>&#160;      <span class="keywordflow">if</span> (<a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>.isValid() &amp;&amp; !m_commited)</div><div class="line"><a name="l00458"></a><span class="lineno">  458</span>&#160;      {</div><div class="line"><a name="l00459"></a><span class="lineno">  459</span>&#160;         m_commited = <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>.commit();</div><div class="line"><a name="l00460"></a><span class="lineno">  460</span>&#160;</div><div class="line"><a name="l00461"></a><span class="lineno">  461</span>&#160;<span class="preprocessor">#ifdef DB_EXCEPTIONS_ENABLED</span></div><div class="line"><a name="l00462"></a><span class="lineno">  462</span>&#160;</div><div class="line"><a name="l00463"></a><span class="lineno">  463</span>&#160;         <span class="keywordflow">if</span> (!m_commited)</div><div class="line"><a name="l00464"></a><span class="lineno">  464</span>&#160;            <span class="keywordflow">throw</span> <a class="code" href="class_d_b_exception.htm">DBException</a>(<a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>);</div><div class="line"><a name="l00465"></a><span class="lineno">  465</span>&#160;</div><div class="line"><a name="l00466"></a><span class="lineno">  466</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00467"></a><span class="lineno">  467</span>&#160;</div><div class="line"><a name="l00468"></a><span class="lineno">  468</span>&#160;      }</div><div class="line"><a name="l00469"></a><span class="lineno">  469</span>&#160;</div><div class="line"><a name="l00470"></a><span class="lineno">  470</span>&#160;      <span class="keywordflow">return</span> m_commited;</div><div class="line"><a name="l00471"></a><span class="lineno">  471</span>&#160;   }</div><div class="line"><a name="l00472"></a><span class="lineno">  472</span>&#160;</div><div class="line"><a name="l00476"></a><span class="lineno"><a class="line" href="class_transaction.htm#a01e20e050a9ee2ba3eecf1b5ed57e2eb">  476</a></span>&#160;   <span class="keywordtype">bool</span> <a class="code" href="class_transaction.htm#a01e20e050a9ee2ba3eecf1b5ed57e2eb">rollback</a>()</div><div class="line"><a name="l00477"></a><span class="lineno">  477</span>&#160;   {</div><div class="line"><a name="l00478"></a><span class="lineno">  478</span>&#160;      <span class="keywordtype">bool</span> res = <span class="keyword">false</span>;</div><div class="line"><a name="l00479"></a><span class="lineno">  479</span>&#160;</div><div class="line"><a name="l00480"></a><span class="lineno">  480</span>&#160;      <span class="keywordflow">if</span> (<a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>.isValid() &amp;&amp; !m_commited)</div><div class="line"><a name="l00481"></a><span class="lineno">  481</span>&#160;      {</div><div class="line"><a name="l00482"></a><span class="lineno">  482</span>&#160;         res = <a class="code" href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">m_db</a>.rollback();</div><div class="line"><a name="l00483"></a><span class="lineno">  483</span>&#160;</div><div class="line"><a name="l00484"></a><span class="lineno">  484</span>&#160;         m_commited = <span class="keyword">false</span>;</div><div class="line"><a name="l00485"></a><span class="lineno">  485</span>&#160;      }</div><div class="line"><a name="l00486"></a><span class="lineno">  486</span>&#160;</div><div class="line"><a name="l00487"></a><span class="lineno">  487</span>&#160;      <span class="keywordflow">return</span> res;</div><div class="line"><a name="l00488"></a><span class="lineno">  488</span>&#160;   }</div><div class="line"><a name="l00489"></a><span class="lineno">  489</span>&#160;</div><div class="line"><a name="l00493"></a><span class="lineno"><a class="line" href="class_transaction.htm#a53d4633727d54be34b7af5d68e7ef0ac">  493</a></span>&#160;   <span class="keywordtype">bool</span> <a class="code" href="class_transaction.htm#a53d4633727d54be34b7af5d68e7ef0ac">started</a>()<span class="keyword"> const</span></div><div class="line"><a name="l00494"></a><span class="lineno">  494</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00495"></a><span class="lineno">  495</span>&#160;      <span class="keywordflow">return</span> m_started;</div><div class="line"><a name="l00496"></a><span class="lineno">  496</span>&#160;   }</div><div class="line"><a name="l00497"></a><span class="lineno">  497</span>&#160;</div><div class="line"><a name="l00501"></a><span class="lineno"><a class="line" href="class_transaction.htm#a87b55e002c7d1b8b2d912c6714a88576">  501</a></span>&#160;   <span class="keywordtype">bool</span> <a class="code" href="class_transaction.htm#a87b55e002c7d1b8b2d912c6714a88576">commited</a>()<span class="keyword"> const</span></div><div class="line"><a name="l00502"></a><span class="lineno">  502</span>&#160;<span class="keyword">   </span>{</div><div class="line"><a name="l00503"></a><span class="lineno">  503</span>&#160;      <span class="keywordflow">return</span> m_commited;</div><div class="line"><a name="l00504"></a><span class="lineno">  504</span>&#160;   }</div><div class="line"><a name="l00505"></a><span class="lineno">  505</span>&#160;</div><div class="line"><a name="l00506"></a><span class="lineno">  506</span>&#160;<span class="keyword">private</span>:   </div><div class="line"><a name="l00507"></a><span class="lineno">  507</span>&#160;   <span class="keywordtype">bool</span> m_commited = <span class="keyword">false</span>;</div><div class="line"><a name="l00508"></a><span class="lineno">  508</span>&#160;   <span class="keywordtype">bool</span> m_started = <span class="keyword">false</span>;   </div><div class="line"><a name="l00509"></a><span class="lineno">  509</span>&#160;};</div><div class="line"><a name="l00510"></a><span class="lineno">  510</span>&#160;</div><div class="line"><a name="l00511"></a><span class="lineno">  511</span>&#160;<span class="preprocessor">#endif // EASYQTSQL_TRANSACTION_H</span></div><div class="ttc" id="class_database_htm_a39dbcd9a97f4e3c38c8c5ba48e445216"><div class="ttname"><a href="class_database.htm#a39dbcd9a97f4e3c38c8c5ba48e445216">Database::scalar</a></div><div class="ttdeci">QVariant scalar(const QString &amp;query) const</div><div class="ttdoc">Executes query and returns scalar value. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:325</div></div>
<div class="ttc" id="class_database_htm_ad2283c7025501aafc33530d19beb02b4"><div class="ttname"><a href="class_database.htm#ad2283c7025501aafc33530d19beb02b4">Database::first</a></div><div class="ttdeci">int first(const QString &amp;query, Func &amp;&amp;f) const</div><div class="ttdoc">Executes query and applies function f to the first result row. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:251</div></div>
<div class="ttc" id="class_database_htm_a8388689590c1f3adeabd2972b221bcb2"><div class="ttname"><a href="class_database.htm#a8388689590c1f3adeabd2972b221bcb2">Database::insertInto</a></div><div class="ttdeci">InsertQuery insertInto(const QString &amp;table) const</div><div class="ttdoc">Creates INSERT query wrapper. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:165</div></div>
<div class="ttc" id="class_transaction_htm_a384204be2d6c76f7f6d20d612f487e71"><div class="ttname"><a href="class_transaction.htm#a384204be2d6c76f7f6d20d612f487e71">Transaction::operator=</a></div><div class="ttdeci">Transaction &amp; operator=(Transaction &amp;&amp;other)</div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:429</div></div>
<div class="ttc" id="_easy_qt_sql___insert_query_8h_htm"><div class="ttname"><a href="_easy_qt_sql___insert_query_8h.htm">EasyQtSql_InsertQuery.h</a></div></div>
<div class="ttc" id="class_database_htm_a05c1ac255cdba9781f8bf306801bca70"><div class="ttname"><a href="class_database.htm#a05c1ac255cdba9781f8bf306801bca70">Database::execQuery</a></div><div class="ttdeci">QueryResult execQuery(const QString &amp;sql) const</div><div class="ttdoc">Executes SELECT query. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:145</div></div>
<div class="ttc" id="class_transaction_htm_a87b55e002c7d1b8b2d912c6714a88576"><div class="ttname"><a href="class_transaction.htm#a87b55e002c7d1b8b2d912c6714a88576">Transaction::commited</a></div><div class="ttdeci">bool commited() const</div><div class="ttdoc">Returns true if the transaction has been commited successfully. Otherwise it returns false...</div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:501</div></div>
<div class="ttc" id="class_database_htm_a7357cbeca05937556f66e2fe2288bdb5"><div class="ttname"><a href="class_database.htm#a7357cbeca05937556f66e2fe2288bdb5">Database::m_db</a></div><div class="ttdeci">QSqlDatabase m_db</div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:335</div></div>
<div class="ttc" id="_easy_qt_sql___prepared_query_8h_htm"><div class="ttname"><a href="_easy_qt_sql___prepared_query_8h.htm">EasyQtSql_PreparedQuery.h</a></div></div>
<div class="ttc" id="class_prepared_query_htm"><div class="ttname"><a href="class_prepared_query.htm">PreparedQuery</a></div><div class="ttdoc">Class for query preparation and execution. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_PreparedQuery.h:63</div></div>
<div class="ttc" id="class_database_htm_a3b1fb50c3263775351fc981fda798207"><div class="ttname"><a href="class_database.htm#a3b1fb50c3263775351fc981fda798207">Database::range</a></div><div class="ttdeci">int range(const QString &amp;query, int start, int count, Func &amp;&amp;f) const</div><div class="ttdoc">Executes query and applies function f to count result rows starting from index start. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:275</div></div>
<div class="ttc" id="class_query_result_htm_a5e3b49cb821efecac406606d9e3adb13"><div class="ttname"><a href="class_query_result.htm#a5e3b49cb821efecac406606d9e3adb13">QueryResult::scalar</a></div><div class="ttdeci">T scalar() const</div><div class="ttdoc">Returns scalar value converted to type T (the value of the first column of the current row) ...</div><div class="ttdef"><b>Definition:</b> EasyQtSql_QueryResult.h:424</div></div>
<div class="ttc" id="class_transaction_htm_a01e20e050a9ee2ba3eecf1b5ed57e2eb"><div class="ttname"><a href="class_transaction.htm#a01e20e050a9ee2ba3eecf1b5ed57e2eb">Transaction::rollback</a></div><div class="ttdeci">bool rollback()</div><div class="ttdoc">Rolls back transaction. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:476</div></div>
<div class="ttc" id="class_util_htm_af0d70a7ab17cd3f445cfeda22e367185"><div class="ttname"><a href="class_util.htm#af0d70a7ab17cd3f445cfeda22e367185">Util::range</a></div><div class="ttdeci">static int range(QueryResult &amp;res, int start, int count, Func &amp;&amp;f)</div><div class="ttdoc">Applies function (lambda) f to count rows starting from start index. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Util.h:88</div></div>
<div class="ttc" id="_easy_qt_sql___update_query_8h_htm"><div class="ttname"><a href="_easy_qt_sql___update_query_8h.htm">EasyQtSql_UpdateQuery.h</a></div></div>
<div class="ttc" id="class_transaction_htm_a362b0d2524d0c799165190517192dca9"><div class="ttname"><a href="class_transaction.htm#a362b0d2524d0c799165190517192dca9">Transaction::~Transaction</a></div><div class="ttdeci">~Transaction()</div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:440</div></div>
<div class="ttc" id="class_transaction_htm_a7388031cba0416d48e03e3f7acd5ca6a"><div class="ttname"><a href="class_transaction.htm#a7388031cba0416d48e03e3f7acd5ca6a">Transaction::commit</a></div><div class="ttdeci">bool commit()</div><div class="ttdoc">Commits transaction. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:455</div></div>
<div class="ttc" id="class_database_htm_a2d8dad3df4134306749582216bd437e0"><div class="ttname"><a href="class_database.htm#a2d8dad3df4134306749582216bd437e0">Database::update</a></div><div class="ttdeci">UpdateQuery update(const QString &amp;table) const</div><div class="ttdoc">Creates UPDATE query wrapper. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:187</div></div>
<div class="ttc" id="class_non_query_result_htm"><div class="ttname"><a href="class_non_query_result.htm">NonQueryResult</a></div><div class="ttdoc">QSqlQuery wrapper for non-select query results reading. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_NonQueryResult.h:38</div></div>
<div class="ttc" id="class_transaction_htm_a53d4633727d54be34b7af5d68e7ef0ac"><div class="ttname"><a href="class_transaction.htm#a53d4633727d54be34b7af5d68e7ef0ac">Transaction::started</a></div><div class="ttdeci">bool started() const</div><div class="ttdoc">Returns true if the transaction has been started successfully. Otherwise it returns false...</div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:493</div></div>
<div class="ttc" id="class_util_htm_a8b0d3aaa507f4f4add129795a2cd6247"><div class="ttname"><a href="class_util.htm#a8b0d3aaa507f4f4add129795a2cd6247">Util::top</a></div><div class="ttdeci">static int top(QueryResult &amp;res, int topCount, Func &amp;&amp;f)</div><div class="ttdoc">Applies function (lambda) f to topCount rows from res. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Util.h:122</div></div>
<div class="ttc" id="class_database_htm_a7bc0ce48d3711002d4e0490c826f7b5e"><div class="ttname"><a href="class_database.htm#a7bc0ce48d3711002d4e0490c826f7b5e">Database::lastError</a></div><div class="ttdeci">QSqlError lastError() const</div><div class="ttdoc">Returns information about the last error that occurred on the underlying database. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:114</div></div>
<div class="ttc" id="class_database_htm_a909783661db7d15e0b0adca5a96db4de"><div class="ttname"><a href="class_database.htm#a909783661db7d15e0b0adca5a96db4de">Database::scalar</a></div><div class="ttdeci">T scalar(const QString &amp;query) const</div><div class="ttdoc">Executes query and returns scalar value converted to T. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:311</div></div>
<div class="ttc" id="class_database_htm"><div class="ttname"><a href="class_database.htm">Database</a></div><div class="ttdoc">QSqlDatabase wrapper. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:67</div></div>
<div class="ttc" id="class_database_htm_a2a81e06933bf2ef5be2e59030a7e1e1c"><div class="ttname"><a href="class_database.htm#a2a81e06933bf2ef5be2e59030a7e1e1c">Database::operator=</a></div><div class="ttdeci">Database &amp; operator=(Database &amp;&amp;other)</div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:101</div></div>
<div class="ttc" id="class_database_htm_a0076431e130f7815ca7a3ae8ec7284ef"><div class="ttname"><a href="class_database.htm#a0076431e130f7815ca7a3ae8ec7284ef">Database::qSqlDatabase</a></div><div class="ttdeci">QSqlDatabase &amp; qSqlDatabase()</div><div class="ttdoc">Returns a reference to the wrapped QSqlDatabase object. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:209</div></div>
<div class="ttc" id="class_delete_query_htm"><div class="ttname"><a href="class_delete_query.htm">DeleteQuery</a></div><div class="ttdoc">QSqlQuery wrapper for DELETE FROM ... WHERE .. query execution. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_DeleteQuery.h:39</div></div>
<div class="ttc" id="class_transaction_htm_a25916a5c0268d3b24a1fe17acf49fd95"><div class="ttname"><a href="class_transaction.htm#a25916a5c0268d3b24a1fe17acf49fd95">Transaction::Transaction</a></div><div class="ttdeci">Transaction(Transaction &amp;&amp;other)</div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:419</div></div>
<div class="ttc" id="class_database_htm_afe82d7c8e0e895c0b4f9fa08b4e3eb8e"><div class="ttname"><a href="class_database.htm#afe82d7c8e0e895c0b4f9fa08b4e3eb8e">Database::Database</a></div><div class="ttdeci">Database(Database &amp;&amp;other)</div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:95</div></div>
<div class="ttc" id="class_database_htm_aae9f7e53275334c91655eeb7a2bde030"><div class="ttname"><a href="class_database.htm#aae9f7e53275334c91655eeb7a2bde030">Database::execNonQuery</a></div><div class="ttdeci">NonQueryResult execNonQuery(const QString &amp;sql) const</div><div class="ttdoc">Executes non-query SQL statement (DELETE, INSERT, UPDATE, CREATE, ALTER, etc.) </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:124</div></div>
<div class="ttc" id="_easy_qt_sql___delete_query_8h_htm"><div class="ttname"><a href="_easy_qt_sql___delete_query_8h.htm">EasyQtSql_DeleteQuery.h</a></div></div>
<div class="ttc" id="class_database_htm_a7a13f4fc603fb829f123894d9abd6ea7"><div class="ttname"><a href="class_database.htm#a7a13f4fc603fb829f123894d9abd6ea7">Database::each</a></div><div class="ttdeci">int each(const QString &amp;query, Func &amp;&amp;f) const</div><div class="ttdoc">Executes query and applies function f to each result row. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:229</div></div>
<div class="ttc" id="class_database_htm_a44fca4a9c9241481a87d59f529e98b9e"><div class="ttname"><a href="class_database.htm#a44fca4a9c9241481a87d59f529e98b9e">Database::deleteFrom</a></div><div class="ttdeci">DeleteQuery deleteFrom(const QString &amp;table) const</div><div class="ttdoc">Creates DELETE query wrapper. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:176</div></div>
<div class="ttc" id="class_query_result_htm"><div class="ttname"><a href="class_query_result.htm">QueryResult</a></div><div class="ttdoc">QSqlQuery wrapper with handy data fetch methods. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_QueryResult.h:39</div></div>
<div class="ttc" id="class_database_htm_a03e2c9113452bb52bb7018ef2366bce1"><div class="ttname"><a href="class_database.htm#a03e2c9113452bb52bb7018ef2366bce1">Database::prepare</a></div><div class="ttdeci">PreparedQuery prepare(const QString &amp;sql, bool forwardOnly=true) const</div><div class="ttdoc">Prepares SQL statement. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:199</div></div>
<div class="ttc" id="class_transaction_htm"><div class="ttname"><a href="class_transaction.htm">Transaction</a></div><div class="ttdoc">QSqlDatabase transaction wrapper. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:398</div></div>
<div class="ttc" id="class_util_htm_a08e77f4051011d51e9d79339a839580a"><div class="ttname"><a href="class_util.htm#a08e77f4051011d51e9d79339a839580a">Util::first</a></div><div class="ttdeci">static int first(QueryResult &amp;res, Func &amp;&amp;f)</div><div class="ttdoc">Applies function (lambda) f to first result row. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Util.h:133</div></div>
<div class="ttc" id="_easy_qt_sql___util_8h_htm"><div class="ttname"><a href="_easy_qt_sql___util_8h.htm">EasyQtSql_Util.h</a></div></div>
<div class="ttc" id="class_query_result_htm_a1c756382c20c126979b28715d529c054"><div class="ttname"><a href="class_query_result.htm#a1c756382c20c126979b28715d529c054">QueryResult::next</a></div><div class="ttdeci">bool next()</div><div class="ttdoc">Retrieves the next record in the result, if available, and positions the query on the retrieved recor...</div><div class="ttdef"><b>Definition:</b> EasyQtSql_QueryResult.h:60</div></div>
<div class="ttc" id="class_util_htm_ab212a05ceda1f1060b772f6908253af2"><div class="ttname"><a href="class_util.htm#ab212a05ceda1f1060b772f6908253af2">Util::each</a></div><div class="ttdeci">static int each(QueryResult &amp;res, Func &amp;&amp;f)</div><div class="ttdoc">Applies function (lambda) f to each row in res. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Util.h:64</div></div>
<div class="ttc" id="_easy_qt_sql___d_b_exception_8h_htm"><div class="ttname"><a href="_easy_qt_sql___d_b_exception_8h.htm">EasyQtSql_DBException.h</a></div></div>
<div class="ttc" id="class_transaction_htm_a9fed08d5643b66471a6e9fc75f351117"><div class="ttname"><a href="class_transaction.htm#a9fed08d5643b66471a6e9fc75f351117">Transaction::Transaction</a></div><div class="ttdeci">Transaction(const QSqlDatabase &amp;db=QSqlDatabase())</div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:404</div></div>
<div class="ttc" id="class_insert_query_htm"><div class="ttname"><a href="class_insert_query.htm">InsertQuery</a></div><div class="ttdoc">QSqlQuery wrapper for INSERT INTO table query execution. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_InsertQuery.h:39</div></div>
<div class="ttc" id="class_database_htm_a91583d42e701fb399563facc3c3c58c0"><div class="ttname"><a href="class_database.htm#a91583d42e701fb399563facc3c3c58c0">Database::top</a></div><div class="ttdeci">int top(const QString &amp;query, int topCount, Func &amp;&amp;f) const</div><div class="ttdoc">Executes query and applies function f to topCount result rows. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:298</div></div>
<div class="ttc" id="class_database_htm_a252b2bb8aeb0c0a2509b0eddf0be3c4e"><div class="ttname"><a href="class_database.htm#a252b2bb8aeb0c0a2509b0eddf0be3c4e">Database::Database</a></div><div class="ttdeci">Database(const QSqlDatabase &amp;db=QSqlDatabase())</div><div class="ttdef"><b>Definition:</b> EasyQtSql_Transaction.h:80</div></div>
<div class="ttc" id="class_update_query_htm"><div class="ttname"><a href="class_update_query.htm">UpdateQuery</a></div><div class="ttdoc">QSqlQuery wrapper for UPDATE ... SET ... WHERE ... query execution. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_UpdateQuery.h:39</div></div>
<div class="ttc" id="class_d_b_exception_htm"><div class="ttname"><a href="class_d_b_exception.htm">DBException</a></div><div class="ttdoc">Exception class for SQL errors handling. </div><div class="ttdef"><b>Definition:</b> EasyQtSql_DBException.h:38</div></div>
<div class="ttc" id="_easy_qt_sql___non_query_result_8h_htm"><div class="ttname"><a href="_easy_qt_sql___non_query_result_8h.htm">EasyQtSql_NonQueryResult.h</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_ccd1b38e141953c502dde9cd8646e4d8.htm">EasyQtSql</a></li><li class="navelem"><a class="el" href="_easy_qt_sql___transaction_8h.htm">EasyQtSql_Transaction.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
